package controllers;

import play.cache.Cache;
import play.mvc.Controller;
import prefix.platform.Constants;
import prefix.platform.session.LoginSession;

public class BaseController extends Controller {
    

    protected void createLoginSession(LoginSession newActor) {
        String uuid = session("uuid");
        if (uuid == null) {
            uuid = java.util.UUID.randomUUID().toString();
            session("uuid", uuid);
        }
        Cache.set(uuid + "item.key", newActor, LoginSession.m_sessionTimeout);
    }

    protected void refreshLoginSession() {
        LoginSession loginSession = Cache.get(session("uuid") + Constants.SESSION_AUTH_KEY) == null ? null : (LoginSession) Cache
                .get(session("uuid") + Constants.SESSION_AUTH_KEY);
        if (loginSession != null) {
            Cache.set(session("uuid") + "item.key", loginSession, LoginSession.m_sessionTimeout);
        }
    }

    private String generateSessionID() {
        return java.util.UUID.randomUUID().toString();
    }
}
